﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Shop.Order.Models;
using PetaPoco;
using Shop.Order.Services;

namespace Shop.Order.Services
{
    /// <summary>
    /// 
    /// </summary>
    public class CourierAccess
    {
        Repositories.CourierAccess dal = new Repositories.CourierAccess();
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IList<Models.CourierCategory> GetCCInfo()
        {
            return dal.GetCCInfo();
        }
        /// <summary>
        /// 添加类别
        /// </summary>
        /// <param name="ccinfo"></param>
        /// <returns></returns>
        public object AddCourierCategory(CourierCategory ccinfo)
        {
            return dal.AddCourierCategory(ccinfo);
        }
        /// <summary>
        /// 删除类别
        /// </summary>
        /// <param name="CCID"></param>
        /// <returns></returns>
        public int DelCourierCategory(int CCID)
        {
            return dal.DelCourierCategory(CCID);
        }
        /// <summary>
        /// ID
        /// </summary>
        /// <param name="CCID"></param>
        /// <returns></returns>
        public IList<Models.Courier> GetCCInfo(int CCID)
        {
            return dal.GetCCount(CCID);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CCID"></param>
        /// <returns></returns>
        public int GetCCount(int CCID)
        {
            return dal.GetCCount(CCID).Count;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CCID"></param>
        /// <returns></returns>
        public int UpdateCourierCategory(CourierCategory ccinfo)
        {
            return dal.UpdateCourierCategory(ccinfo);
        }


        /// <summary>
        /// 验证子类别名是否存在
        /// </summary>
        /// <param name="CName">子类别名</param>
        /// <returns></returns>
        public int VerificationCName(string CName)
        {
            CourierCategory cinfo = dal.VerificationCName(CName);
            //如果为空的话说明不存在
            if (cinfo == null)
            {
                return 1;
            }
            return 0;
        }
        /// <summary>
        /// 修改类别时验证子类别名存不存在
        /// </summary>
        /// <param name="CName">类别名</param>
        /// <returns></returns>
        public int UVerificationCName(string CName, string YCName)
        {
            CourierCategory cinfo = dal.VerificationCName(CName);
            //如果为空的话说明不存在
            if (cinfo == null)
            {
                return 1;
            }
            //如果输入的和原来的一样的话是可以的
            else if (cinfo.CName == YCName)
            {
                return 1;
            }
            return 0;
        }

        /// <summary>
        /// </summary>
        /// <param name="CCID"></param>
        /// <returns></returns>
        public CourierCategory GetCCInfo(int CCID,string wuyong)
        {
            return dal.GetCCInfo(CCID);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CourierNumber"></param>
        /// <returns></returns>
        public Courier GetCInfo(string CourierNumber)
        {
            return dal.GetCInfo(CourierNumber);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CCode"></param>
        /// <returns></returns>
        public CourierCategory GetCCInfo(string CCode)
        {
            return dal.GetCCInfo(CCode);
        }
        //
        public object AddCourier(Courier cinfo)
        {
            return dal.AddCourier(cinfo);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Page">第几页</param>
        /// <param name="PageNum">每页多少条</param>
        /// <param name="Status">订单状态</param>
        /// <param name="Strart">开始时间</param>
        /// <param name="End">结束时间</param>
        /// <param name="SearchType">搜索类型</param>
        /// <param name="Search">搜索内容</param>
        /// <param name="order">排序方式</param>
        /// <param name="CCode"></param>
        /// <returns></returns>
        public Page<Models.AnyCourier> GetCinfo(long Page, long PageNum, int Status, string Strart, string End, int SearchType, string Search, int order, string CCode)
        {
            return dal.GetCinfo(Page, PageNum, Status, Strart, End, SearchType, Search, order, CCode);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CID">ID</param>
        /// <returns></returns>
        public int DelCourier(int CID)
        {
            return dal.DelCourier(CID);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CCode"></param>
        /// <returns></returns>
        public int VCourierCategory(string CCode)
        {
            return dal.VCourierCategory(CCode).Count;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CCode"></param>
        /// <returns></returns>
        public Courier GetCurier(string CCode)
        {
            return dal.GetCurier(CCode);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CourierNumber"></param>
        /// <returns></returns>
        public int UseCourier(string CourierNumber)
        {
            return dal.UseCourier(CourierNumber);
        }
    }
}
